#ifndef SOUND_H_
#define SOUND_H_
#include <MAUtil/Moblet.h>
#include <mastdlib.h>
#include <NativeUI/Widgets.h>
#include <ma.h>
#include <mavsprintf.h>
#include <NativeUI/WidgetUtil.h>
#include <MAUtil/Graphics.h>
#include "MAHeaders.h"
#include <MAUtil/Vector.h>
#include <MAUI/Screen.h>
#include <MAUI/Layout.h>
#include <MAUI/Label.h>
#include <MAUI/Font.h>
#include <mastdlib.h>

using namespace MAUtil;
using namespace NativeUI;

class Sound
{
	private:
		MAAudioData mData[4];
		MAAudioInstance mInstance[4];

	public:

	    Sound()
	    {
	            mData[0] = maAudioDataCreateFromResource(
	                    NULL, INTRO_MUSIC, 0, maGetDataSize(INTRO_MUSIC), 1);
	            mData[1] = maAudioDataCreateFromResource(
	                     NULL, LEVEL1_MUSIC, 0, maGetDataSize(LEVEL1_MUSIC),1);
	            mData[2] = maAudioDataCreateFromResource(
	                     NULL, JUMP_SOUND, 0, maGetDataSize(JUMP_SOUND),0);
	            mData[3] = maAudioDataCreateFromResource(
	            	     NULL, COLLISION_SOUND, 0, maGetDataSize(COLLISION_SOUND),0);

	            mInstance[0] = maAudioInstanceCreate(mData[0]);
	            mInstance[1] = maAudioInstanceCreate(mData[1]);
	            mInstance[2] = maAudioInstanceCreate(mData[2]);
	            mInstance[3] = maAudioInstanceCreate(mData[3]);
	    }

	    void PlayIntro()
	    {
	    	//maAudioSetNumberOfLoops(mInstance[0], -1);
	    	maAudioPlay(mInstance[0]);
	    }

	    void StopIntro()
	    {
	    	maAudioStop(mInstance[0]);
	    	maAudioSetPosition(mInstance[0], 0);
	    }

	    void PlayLevel1()
	    {
	    	//maAudioSetNumberOfLoops(mInstance[1], -1);
	    	maAudioPlay(mInstance[1]);
	    }

	    void StopLevel1()
	    {
	    	maAudioStop(mInstance[1]);
	    	maAudioSetPosition(mInstance[1], 0);
	    }

	    void PlayJump()
	    {
	    	maAudioPlay(mInstance[2]);
	    }

	    void PlayCollision()
	    {
	    	maAudioPlay(mInstance[3]);
	    }

	    void StopAll()
	    {
	    	for(int i = 0; i < 3; i++)
	    		maAudioStop(mInstance[i]);
	    }

};

#endif
